package com.jinmdz.fmis.dao.dao.provider;

import com.jinmdz.fmis.dao.base.BaseProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

import java.util.ArrayList;

/**
 * 费用结算付款Provider
 *
 * @author LiCongLu
 * @date 2020-05-13 15:09
 */
public class ChargeSettlePayProvider extends BaseProvider {


    /**
     * 按照结算主键获取付款信息
     *
     * @param businessCode 业务编码
     * @param settleIds    结算主键集合
     * @return
     * @author LiCongLu
     * @date 2020-05-13 15:10
     */
    public String listChargeSettlePayBySettleIds(@Param("businessCode") String businessCode, @Param("settleIds") ArrayList<Integer> settleIds) {
        return new SQL() {
            {
                StringBuilder builder = new StringBuilder();
                builder.append(" id,business_code,charge_settle_id,pay_type_code,pay_charge,pay_time,random_code,version ");
                SELECT(builder.toString());
                FROM(" charge_settle_pay ");
                WHERE(" deleted = 0 ");
                WHERE(" business_code = #{businessCode} ");
                // 主键
                String idString = StringUtils.arrayToDelimitedString(settleIds.toArray(new Integer[]{}), ",");
                WHERE("  charge_settle_id in (" + idString + ")");
            }
        }.toString();
    }
}